home *** CD-ROM | disk | FTP | other *** search
- unit Main;
-
- interface
-
- uses
- SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
- Forms, Dialogs, StdCtrls, ExtCtrls, MPlayer;
-
- type
- TformMain = class(TForm)
- MediaPlayer: TMediaPlayer;
- timerHora: TTimer;
- buttonFale: TButton;
- labelHora: TLabel;
- procedure FormCreate(Sender: TObject);
- procedure timerHoraTimer(Sender: TObject);
- procedure buttonFaleClick(Sender: TObject);
- private
- { Private declarations }
- Sons : String;
- procedure Fala(Arquivo:String);
- public
- { Public declarations }
- end;
-
- var
- formMain: TformMain;
-
- implementation
-
- {$R *.DFM}
-
- procedure TformMain.FormCreate(Sender: TObject);
- begin
- {Seta a localizaτπo da pasta SONS, dentro da pasta do
- nosso programa, onde quer que ele esteja}
- Sons := ExtractFilePath(Application.ExeName);
- if Sons[Length(Sons)]<>'\' then Sons := Sons + '\';
- Sons := Sons + 'SONS\';
- {Executa a rotina do Timer, para exibir a hora logo no inφcio}
- timerHoraTimer(timerHora);
- end;
-
- procedure TformMain.timerHoraTimer(Sender: TObject);
- begin
- {Exibe a hora}
- labelHora.Caption := Copy(TimetoStr(Time),1,5);
- end;
-
- {"Fala" o arquivo especificado}
- procedure TformMain.Fala(Arquivo:String);
- begin
- {Adiciona o caminho e a extensπo .WAV ao arquivo}
- Arquivo := Sons+Arquivo+'.WAV';
- {Se o arquivo nπo existir, sai da procedure}
- if not FileExists(Arquivo) then Exit;
- {"Toca" o arquivo}
- MediaPlayer.FileName := Arquivo;
- try
- MediaPlayer.Open;
- MediaPlayer.Play;
- {MantΘm o windows "trabalhando" sem sair da procedure
- enquanto o arquivo estiver sendo reproduzido}
- While MediaPlayer.Position < MediaPlayer.Length do
- Application.ProcessMessages;
- finally
- MediaPlayer.Close;
- end;
- end;
-
- procedure TformMain.buttonFaleClick(Sender: TObject);
- var Hora, Minuto : Integer;
- begin
- {Converte a hora e o minuto p/ inteiros}
- Hora := StrToInt(Copy(labelHora.Caption,1,2));
- Minuto := StrToInt(Copy(labelHora.Caption,4,2));
- {"Fala" a hora}
- if Hora<=20 then
- begin
- Case Hora of
- 1:Fala('1h');
- 2:Fala('2h');
- else Fala(IntToStr(Hora));
- end;
- end else
- begin
- Fala(IntToStr((Hora div 10)*10));
- if Hora mod 10 <> 0 then
- begin
- Fala('e');
- Fala(IntToStr(Hora mod 10));
- end;
- end;
- if Hora<>1 then Fala('horas') else Fala('hora');
- {"Fala" os minutos, se necessßrio}
- if Minuto<>0 then
- begin
- Fala('e');
- if Minuto<=20 then Fala(IntToStr(Minuto)) else
- begin
- Fala(IntToStr((Minuto div 10)*10));
- if Minuto mod 10 <> 0 then
- begin
- Fala('e');
- Fala(IntToStr(Minuto mod 10));
- end;
- end;
- if Minuto<>1 then Fala('minutos') else Fala('minuto');
- end;
- end;
-
- end.
-